package com.example.blog.admin.controller;

import com.example.blog.admin.service.TagsService;
import com.example.blog.admin.vo.Result;
import com.example.blog.admin.vo.TagVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("tags")
public class TagsController {

    @Autowired
    TagsService tagsService;

    @GetMapping("hot")
    public Result listHotTags() {
        int limit = 6;
        List<TagVo> tagVoList = tagsService.findHotTags(limit);

        return Result.success(tagVoList);
    }

    @GetMapping
    public Result listAllTags() {
        return tagsService.findAllTags();
    }

    @GetMapping("detail")
    public Result listAllTagsDetail() {
        return tagsService.findAllTagsDetail();
    }

    @GetMapping("detail/{id}")
    public Result listTagsDetailById(@PathVariable("id") Long tagId) {
        return tagsService.findTagsDetailById(tagId);
    }
}
